VERSION 5.00
Begin VB.Form RenameForm 
   Caption         =   "New Species Name"
   ClientHeight    =   2880
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6660
   LinkTopic       =   "Form2"
   ScaleHeight     =   2880
   ScaleWidth      =   6660
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox NewSpeciesName 
      Height          =   375
      Left            =   2280
      TabIndex        =   2
      Text            =   "Text1"
      Top             =   600
      Width           =   4215
   End
   Begin VB.CommandButton CancelButton 
      Caption         =   "Cancel"
      Height          =   375
      Left            =   3720
      TabIndex        =   1
      Top             =   2400
      Width           =   1215
   End
   Begin VB.CommandButton OKButton 
      Caption         =   "OK"
      Height          =   375
      Left            =   5280
      TabIndex        =   0
      Top             =   2400
      Width           =   1215
   End
   Begin VB.Label Label2 
      Caption         =   $"RenameForm.frx":0000
      Height          =   1215
      Left            =   240
      TabIndex        =   4
      Top             =   1080
      Width           =   6255
   End
   Begin VB.Label Label1 
      Caption         =   "New Species Name:"
      Height          =   255
      Left            =   240
      TabIndex        =   3
      Top             =   600
      Width           =   1935
   End
End
Attribute VB_Name = "RenameForm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub CancelButton_Click()
  Unload Me
End Sub

Private Sub Form_Load()
Dim ind As Integer
Dim i As Integer
 
  ind = optionsform.SpecList.ListIndex
  If ind >= 0 Then
    NewSpeciesName.text = optionsform.SpecList.text
  Else
    NewSpeciesName.text = "Species Not Found"
  End If
End Sub

Private Sub OKButton_Click()
Dim ind As Integer
Dim i As Integer
Dim t As Integer
 
  ind = optionsform.SpecList.ListIndex
  If ind >= 0 Then
    For i = 1 To MaxRobs
      If rob(i).FName = optionsform.SpecList.text Then
        rob(i).FName = NewSpeciesName.text
      End If
    Next i
       
    'Now figure out if the new name already exists and delete the selected one if so
    For i = 0 To TmpOpts.SpeciesNum - 1
      If TmpOpts.Specie(i).Name = optionsform.SpecList.text Then
        'Rename the speices
        TmpOpts.Specie(i).Name = NewSpeciesName.text
      ElseIf TmpOpts.Specie(i).Name = NewSpeciesName.text Then
        'Delete the seleted species
        For t = i + 1 To TmpOpts.SpeciesNum - 1 'Listcount now has one fewer than it did before!!!
          TmpOpts.Specie(t - 1) = TmpOpts.Specie(t)
        Next t
        TmpOpts.SpeciesNum = TmpOpts.SpeciesNum - 1
      End If
    Next i
  End If
  
  Unload Me
End Sub
